// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Algo_Alert

//@version=5
indicator(title="Squeeze & Release [Algo Alert]", shorttitle="𝓢&𝓡 [Algo Alert]", overlay=false, timeframe="", timeframe_gaps=true)
length = input.int(title="Calculation Period", defval=14, minval=1)
len = input.int(title="Smoothing Length", defval=7, minval=1)
leng = input.int(title="EMA Length", defval=7, minval=1)
le = input.int(title="Hyper Squeeze Detection Length", defval=5, minval=1)
smooth = input.bool(true)
green = input.color(#0087ff, "Release Color") //#00ffbb
red = input.color(#ff1100, "Squeeze Color") //#ff1100

a = ta.ema(ta.tr(true), length)
ama = ta.ema(a, length*2)
v = ama-a
sv = smooth ? ta.ema(v / (ta.ema(high - low, length*2)) * 100, len) : v / (ta.ema(high - low, length*2)) * 100
svma = ta.ema(sv, 14)
ma = plot(svma, color = color.gray)
val = plot(sv, title = "ATR", color = sv > svma ? color.new(red, 0) : color.new(green, 0))
mid = plot(0, style = plot.style_cross, color = sv > 0 and ta.rising(sv, le) ? color.white : color.new(color.white, 70), linewidth = 2) 
plotchar(ta.crossover(sv,svma) ? svma - 10 : na, "Squeeze", char = "𝓢", location = location.absolute, color = red, size = size.tiny)
plotchar(ta.crossunder(sv,svma) ? svma + 10 : na, "Release", char = "𝓡", location = location.absolute, color = green, size = size.tiny)

fillcol = sv > svma ? color.new(red, 0) : color.new(green, 0)

fill(ma, val, sv, svma, fillcol, color.new(chart.bg_color, 100))